package com.itheima.subway.info.manage.controller;

import com.itheima.subway.info.manage.domain.Subways;
import com.itheima.subway.info.manage.service.CheckService;

import java.util.Scanner;

public class CheckController {

    public static void checkSuvways() {
        Scanner sc = new Scanner(System.in);

        while (true) {
            System.out.println("请输入您要查看的地铁站：");
            String next = sc.next();

            boolean exists = CheckService.isExists(next);

            if (exists) {
                Subways subway = CheckService.getSubway(next);
                if (subway != null) {
                    System.out.println(subway);
                    break;
                }
            } else {
                System.out.println("您输入的地铁站不存在，请添加后再查询！");
                break;
            }
        }
    }
}
